#ifndef TESTFRAMEWORK_H
#define TESTFRAMEWORK_H

/*
Copyright (c) 1997-2015, John M. Boyer
All rights reserved.
See the LICENSE.TXT file for licensing information.
*/

#include "../graph.h"

#ifdef __cplusplus
extern "C" {
#endif

#define NUMCOMMANDSTOTEST	7
extern char *commands;

// numGraphs: the number of graphs that met the test criteria
//            (e.g. were generated and had a specific number of edges)
// numOKs: the number of graphs on which the test produced OK
//         (as opposed to NONEMBEDDABLE (or NOTOK))
typedef struct
{
	unsigned long numGraphs;
	unsigned long numOKs;
} baseTestResultStruct;

// command: Indicates the algorithm being tested
// result: Cumulative result of tests on graphs of all sizes
//         (i.e. numbers of edges; the number of vertices is fixed
//          within a given test)
// edgeResults*: Array to accumulateresult of tests on graphs of a
//               each fixed size (i.e. fixed number of edges)
// theGraph: a graph data structure on which each test is performed
//           The graph is preconfigured with a number of vertices
//           and a specific algorithm extension.
// origGraph: a copy of the graph being tested before the algorithm
//            is run on it. This is needed for integrity checking of
//            an algorithm's result produced in theGraph
//            The origGraph from algResult[0] in th test framework
//            receives the edges from the adjacency matrix graph
//            generated by Nauty.  Then, gp_CopyAdjacencyLists() is
//            used to copy the edges of this graph into the origGraph
//            of each other algorithm testResult (if any).
typedef struct
{
	char command;
	baseTestResultStruct result;
	baseTestResultStruct *edgeResults;
	int edgeResultsSize;
	graphP theGraph, origGraph;
} testResultStruct;

typedef testResultStruct * testResultP;

// algResults: An array of testResults for each algorithm being tested
// algResultsSize: the number of algorithms being tested
typedef struct
{
	testResultStruct *algResults;
	int algResultsSize;
} testResultFrameworkStruct;

typedef testResultFrameworkStruct * testResultFrameworkP;

// Returns a pointer to the testResult for the given command character
// or NULL if there is no test result for the algorithm
testResultP tf_GetTestResult(testResultFrameworkP framework, char command);

// Allocate the test framework for the given command. The number of vertices
// and maximum number of edges in the graphs to be tested are also given.
testResultFrameworkP tf_AllocateTestFramework(char command, int n, int maxe);

// Free the test framework.
void tf_FreeTestFramework(testResultFrameworkP *pTestFramework);

#ifdef __cplusplus
}
#endif

#endif
